package actors

import akka.actor.{Actor, ActorRef, Props}
import akka.routing.{RoundRobinGroup, RoundRobinPool}
import halo.actors.Leader
import halo.messages.{Run, StartTask, StopTask}

/**
  * Created by jedi on 17-5-20.
  */
class Manager extends Actor{
  var wrokGroup = 8
  var groupRouter:ActorRef = null
  override def receive: Receive = {

      case Run() =>{
          println("启动")
          groupRouter = this.context.actorOf(Props.create(classOf[Leader]).withRouter(new RoundRobinPool(wrokGroup)))
          context.become(online)
      }
      case _ => {
        println("收到奇怪消息")
        //暂存
      }
  }

  def online:Receive = {
    case StartTask(config) => {
      println(config)
      groupRouter ! StartTask(config)
    }
    case StopTask(config) => {

    }
  }


}
